package com.tjbklx1.redis.chap03;

import org.junit.Test;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

public class App01 {

	@Test
	public void incr() {

		Jedis redis = null;
		try {
			JedisPool pool = new JedisPool("localhost", 6379);
			redis = pool.getResource();
			String key ="key";
			System.out.println(redis.get(key));
			redis.incr(key);
			System.out.println(redis.get(key));
			redis.incrBy(key,15L);
			System.out.println(redis.get(key));
			redis.decr(key);
			System.out.println(redis.get(key));
			redis.decrBy(key,15L);
			System.out.println(redis.get(key));
			redis.set(key, "200");
			System.out.println(redis.get(key));
			redis.incr(key);
			System.out.println(redis.get(key));

		} catch (Exception e) {
			e.printStackTrace();
			if (redis != null) {
				redis.close();
			}
			e.printStackTrace();
		} finally {
			if (redis != null) {
				redis.close();
			}
		}

	}

}
